Day 1: Concepts and a basic workflow
September 23, 2023
Scientific programmer @ theoretical ecology group
Git is a huge topic and Git is very powerful.
Learn simple Git workflows in theory and practice that you can immediately apply to your research projects.
Material is all online
Certificate of attendance from the graduate center
Feedback is very welcome
Just interrupt me for questions/comments
Did anyone have problems with the workshop preparation?
Two examples in which proper version control can be a time/stress saver
Complete and long-term history of every file in your project
Open source and free to use version control software
Quasi standard for software development
A whole universe of other software and services around it
For projects with mainly text files (e.g. code, markdown files, …)
Basic idea: Take snapshots (commits) of your project over time
Git is a distributed version control system
After you installed it there are different ways to interact with the software.
Using Git from the terminal
➕ Most control
➕ A lot of help/answers online
➖ You need to use terminal 😱
A Git GUI is integrated in most (all?) IDEs, e.g. R Studio, VS Code
➕ Easy and intuitive
➕ Stay inside IDE
➖ Different for every program
Standalone Git GUI software, e.g. Github Desktop, Source Tree, …
➕ Easy and intuitive
➕ Use for all projects
➖ Switch programs to use Git
Tip
Have a look at the website where you find How-To guides for the other methods as well.
git init,git add,git commit,git push
A cook book project to collect all my favorite recipes.
Git detects any changes in the working directory
Staging a file means to list it for the next commit.
✔️
See here for more details but some general rules:
Start your own cook book
Complete task 1 “Local repo” (10 - 15 min)
Stay in the meeting for the task.
Ask if you are stuck.
Turn down/off volume if you are disturbed.
Use remote repos (on a server) to synchronize, share and collaborate
Remote repos can be private (you + collaborators) or public (visible to anyone)
Publish your cook book on Github
Checkout your repositories Github page (Repository -> View on GitHub) 5 min
git init: Initialize a git repository
.git folder to your working directorygit add: Add files to the staging area
git commit: Take a snapshot of your current project version
git push: Push new commits to the remote repository
git revert
git revert to revert specific commitsRevert a commit from your cook book
Github/Gitlab are a good way to publish and share your work.
You can increase the quality/complexity of your repo by
Questions?
git checkout
git checkout.gitignoreCreate a file with the name .gitignore in working directory
Add all files and directories you want to ignore to the .gitignore file
.gitignoreCreate a file with the name .gitignore in working directory
Add all files and directories you want to ignore to the .gitignore file
*.html # ignore all .html files
*.pdf # ignore all .pdf files
debug.log # ignore the file debug.log
build/ # ignore all files in subdirectory buildSee here for more ignore patterns that you can use.
Now please
Basic Git workflow